package com.wawayaya.bean;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by creative on 15/7/6.
 */
public class ReadRecord implements Cloneable{

    private  Integer   userId;
    private  Integer   bookId;
    private  Long      enterTime;
    private  Long      outTime;

    public ReadRecord() {

    }

    public Object clone() {
        ReadRecord o = null;
        try {
            o = (ReadRecord) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return o;
    }
    public ReadRecord(Integer userId, Integer bookId,
                      Long enterTime, Long outTime) {
        this.userId = userId;
        this.bookId = bookId;
        this.enterTime = enterTime;
        this.outTime = outTime;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getBookId() {
        return bookId;
    }

    public void setBookId(Integer bookId) {
        this.bookId = bookId;
    }

    public Long getEnterTime() {
        return enterTime;
    }

    public void setEnterTime(Long enterTime) {
        this.enterTime = enterTime;
    }

    public Long getOutTime() {
        return outTime;
    }

    public void setOutTime(Long outTime) {
        this.outTime = outTime;
    }

    public static JSONObject toJOSNobj(ReadRecord read) {
        JSONObject jsonObject = new JSONObject();
        try{
            jsonObject.put("userId", read.getUserId());
            jsonObject.put("bookId", read.getBookId());
            jsonObject.put("enterTime", read.getEnterTime());
            jsonObject.put("outTime", read.getOutTime());

        } catch (JSONException jsonException){
            jsonException.printStackTrace();
        }
        return jsonObject;
    }
}
